package com.utis;

public class TK {

    public static void main(String[] args) {

        System.out.println(sum(7));



    }

    public static int sum(int N){
        int A = getNum(0);//就是题意中T0的值
        int B = getNum(1);//就是题意中T1的值

        int S = A+B;


        int C = A + B;//C其時是 T(N-K) ，T2,T3...
        for(int K = 1;N-K>1; K++){
            S =C + getNum(K) + getNum(K-1);//第三个选项
            A=B;
            B=C;
            C=S;
        }

        return S;



    }


    public static int getNum(int T) {
        
        if(T==0){
            return 0;
        }else if (T == 1 || T == 2) {//如果n为1 返回1
            return 1;
        } else {//否则返回n-1与n-2的数值的相加
            return getNum(T - 1) + getNum(T - 2);
        }
    }

}
